<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta name="csrf_token" id="token" content="{{ csrf_token() }}">
    @include('public.h5_head')
    <title>待支付订单</title>
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/rem.js"></script>
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/commoncss/common.css"/>
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/nopay.css?v0.0.1"/>
</head>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/iscroll.js"></script>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/app.js"></script>
<body onload="loaded()">
<div id="box_nopay">
    <div class="wrap">
        <div class="main_nopay">
            <div class="seek" onclick="window.location.href='/user/selectOrders'">
                <div class="seek_img">
                    <img class="seek_pic" src="/img/seek.png" alt="">
                    <p class="seek_name">搜索</p>
                </div>
            </div>
            @if(count($datas) == 0)
            <div class="main_empty">
                <div class="nopay_empty">
                    <div class="nopay_img">
                        <img src="/img/00022.png" alt="" />
                    </div>
                </div>
                <p class="nopay_wrods">目前没有待付款订单</p>
            </div>
            @endif
            @foreach($datas as $data)
            <div class="nopay_product order_{{ $data->id }}" >
                <div class="nopay_title">
                    <div class="nopay_icon">
                        <img src="/img/00004.png" alt="" />
                        <span>{{ $brands[$data->brand] }}</span>
                        <div class="nopay_success">待支付</div>
                    </div>
                    <div class="nopay_code"><span>订单编号：</span>{{ $data->ordernum }}</div>
                </div>
                <div class="nopay_list" onclick="window.location.href='/produc?good_id={{ $data->pro_id }}'">
                    <div class="nopay_list_l">
                        <img src="{{ env('CDN_DOMAIN_NAME') }}/upload/{{ $data->face }}" alt="" class="nopay_list_img" />
                    </div>
                    <div class="nopay_list_r">
                        <div class="nopay_list_name">
                            <p class="nopay_list_tit">{{ $data->title }}</p>
                            <p class="nopay_price">￥<b>{{sprintf("%.2f", $data->total_price/$data->num) }}</b></p>
                        </div>
                        <p class="nopay_list_words">款号：{{ $data->girard }}</p>
                        <div class="nopay_list_color">
                            <p class="nopay_list_hue">颜色：{{ $data->color }}</p>
                            <p class="nopay_list_post">邮费：￥{{ sprintf("%.2f",$data->postage_estimate) }}</p>
                        </div>
                        <div class="nopay_list_b">
                            @if($data->pre_sale == 1)
                                <p class="nopay_list_postage">数量：{{ $data->num }}件</p>
                            @else
                                <p class="nopay_list_postage">数量：{{ $data->num }}手</p>
                            @endif
                            <p class="nopay_sum">合计：<i>￥{{sprintf("%.2f", $data->total_price + $data->postage_estimate) }}</i></p>
                        </div>
                    </div>
                </div>
                <div class="nopay_btn">
                    {{--<span class="agency">代理：{{ $companys[$data->form_company_id] }}</span>--}}
                    <a href="javascript:;" class="del_order" abc="{{ $data->id }}">删除订单</a>
                    <a href="javascript:;" abc="{{ $data->ordernum }}" class="nopay_btn_sure">去支付</a>
                </div>
            </div>
            @endforeach
            <!--添加-->
        </div>
    </div>
    <div class="delDiv" style="display:none;">
        <div class="delDiv_tip">是否确认？</div>
        <div class="delDiv_info">
            <span id="" class="delDiv_info_left">
                <input id="btnCancel" type="button" value="取 消" class="btn-green btnCancel" />
            </span>
            <span id="" class="delDiv_info_right">
                <input id="btnDelTrue" type="button" value="确 认" class="btn-green btnDelTrue" />
            </span>
        </div>
    </div>
    <div class="choice" style="display:none;">
        <div class="choiceT">
            <span class="choice_sp1">×</span>
            <span class="choice_sp2">请选择付款方式</span>
        </div>
        <div class="choiceC">
            <p class="choice_p choice_p_wx">
                <span class="bg_sp2"></span>
                <span class="choice_sp3">微信</span>
                <span class="choice_sp4"><i class="fa fa-circle-thin"></i></span>

            </p>
            <p class="choice_p choice_p_alipay">
                <span class="bg_sp3"></span>
                <span class="choice_sp3">支付宝</span>
                <span class="choice_sp4"><i class="fa fa-circle-thin"></i></span>

            </p>
        </div>
    </div>
    <div class="mask" style="display:none"></div>
    <div class="expurgate" style="display: none;"></div>
    <div class="mask" style="display:none;"></div>
</div>
</body>
<script>
    /*滚动*/
    var myScroll;
    function loaded () {
        setTimeout(function(){
            myScroll = new IScroll('.wrap', {
                mouseWheel: true,
                click: true
            });
        },100);
    }
    document.addEventListener('touchmove', function (e) {e.preventDefault();},false);
    /*点击删除*/
    $(".del_order").off().on("click",function(){
        $(".delDiv").show();
        $(".mask").show();
        var order_id=$(this).attr("abc");
        $(".btnDelTrue").off().on('click',function() {
            $.ajax({
                url: '/user/deleteNoPayOrder',
                type: 'post',
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                data: {order_id: order_id},
                dataType: 'json',
                success: function (data) {
                    $(".delDiv").hide();
                    $(".mask").hide();
                    if(data.success){
                        $(".order_"+order_id).remove();
                        $(".expurgate").text("删除成功");
                        $(".expurgate").show(0).delay(1000).hide(0);
                    }else{
                        $(".expurgate").text(data.msg);
                        $(".expurgate").show(0).delay(1000).hide(0);
                    }
                }
            })
        })
    });
    $(".btnCancel").click(function(){
        $(".delDiv").hide();
        $(".mask").hide();
    });
    $('.nopay_btn_sure').click(function(){
        $(this).attr("disabled","disabled");
        var that=$(this);
        var pro_id = $(this).attr("abc");
        var merchant_id = '1';
        $('.choiceC').attr('abc',pro_id);
        $('.choice').show();
        $('.mask').show();
        that.removeAttr("disabled","disabled");
        $(".provider").stop().slideUp(200);
        $('.choice_p_wx').click(function(){
            $('.choice').hide();
            $('.mask').hide();
            $('.lds-css').show();
            window.location.href='/pay/wechat-pay-view/'+$(this).parent().attr("abc");
        });
        $('.choice_p_alipay').click(function(){
            $('.choice').hide();
            $('.mask').hide();
            $('.lds-css').show();
            window.location.href='/wecCode?ordernum='+$(this).parent().attr("abc");
        });
        $('.choice_sp1').click(function(){
            $('.choice').hide();
            $('.mask').hide();
        });
    });
</script>
</html>
